<template>
  <div class="app-container">
    <el-form :model="searchForm" :inline="true">
      <el-row>
        <el-col :span="20">
          <el-form-item>
            <el-input v-model="searchForm.fuzzy" style="width:250px" placeholder="样品编号/检测类别/检测位置" clearable @keyup.enter.native="handleSearch" />
          </el-form-item>
          <el-form-item>
            <el-select v-model="searchForm.samplepreStatus" clearable style="width:220px" filterable placeholder="请选择样品制备状态">
              <el-option value="0" label="待领样">待领样</el-option>
              <el-option value="1" label="待制备">待制备</el-option>
              <el-option value="2" label="待提交">待提交</el-option>
              <el-option value="3" label="待审核">待审核</el-option>
              <el-option value="4" label="驳回">驳回</el-option>
              <el-option value="5" label="审核通过">审核通过</el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="iconfont icon-chaxun1" @click="handleSearch"> 查询</el-button>
            <el-button type="primary" class="iconfont el-icon-tickets" @click="handleBatchPreOne">&nbsp批量制备样品</el-button>
            <el-button type="primary" style="margin-left: 30px;" @click="batchSamplePresPutIn">一键申请领样</el-button>
<!--            <el-button type="primary" @click="batchsWarehouSampPre">一键申请入库</el-button>-->
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div>
      <el-table
        stripe
        border
        :data="linSampItemData"
        highlight-current-row
        :header-cell-style="{background:'#ECF3FC'}"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <template slot="empty">
          <div class="table_empty">
            <div class="empty_tips">
              <span>
                暂无数据
              </span>
            </div>
          </div>
        </template>
        <el-table-column type="selection" width="50" :selectable="checkSelectableOne" align="center" />
        <el-table-column type="index" width="50" label="序号" fixed="left" align="center" />
        <el-table-column prop="sampleNo" label="样品编号" fixed="left" min-width="150px" align="center" />
        <el-table-column prop="sampleNumber" label="来样送检样品编号" fixed="left" min-width="150px" align="center" />
        <el-table-column prop="secdClassName" label="检测类别" align="center" />
        <el-table-column prop="factorPoint" label="检测位置" align="center" />
        <el-table-column prop="factorName" label="检测因子" width="180" align="center">
          <template slot-scope="row">
            <el-tooltip effect="dark" placement="top">
              <div slot="content" style="max-width: 400px">{{ row.row.factorName}}</div>
              <div class="apostrophe">
                <span>{{ row.row.factorName}}</span>
              </div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="collectUser" label="采样人" align="center" />
        <el-table-column prop="storeLocation" label="放置地点" align="center" />
        <el-table-column prop="samplepreStatus" label="样品制备状态" min-width="110px" align="center">
          <template slot-scope="{row}">
            <span v-if="row.samplepreStatus === null "><el-tag effect="dark" style="background: #82848a;border:none">待领样</el-tag></span>
            <span v-if="row.samplepreStatus === '1' "><el-tag effect="dark" style="background: #1890ff;border:none">待制备</el-tag></span>
            <span v-if="row.samplepreStatus === '2' "><el-tag effect="dark" style="background: #e6a700;border:none">待提交</el-tag></span>
            <span v-if="row.samplepreStatus === '3' "><el-tag effect="dark" style="background: #1890ff;border:none">待审核</el-tag></span>
            <span v-if="row.samplepreStatus === '4' "><el-tag effect="dark" style="background: #ff4949;border:none">驳回</el-tag></span>
            <span v-if="row.samplepreStatus === '5' "><el-tag effect="dark" style="background: #11b95c;border:none">审核通过</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="reject" label="驳回理由" width="100" align="center">
          <template slot-scope="row">
            <el-tooltip effect="dark" placement="top" :content="row.row.reject" class="apostrophe">
               <span>{{ row.row.reject}}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="samplepreUserName" label="审核人" align="center" />
        <el-table-column prop="preTime" label="制备日期" min-width="260px" align="center">
          <template slot-scope="{row}">
            <span>{{row.startTime}}&nbsp;~&nbsp;{{row.endTime}}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" min-width="120px" label="操作">
          <template slot-scope="{row}">
            <el-button type="text" v-if="row.samplepreStatus === null " @click="samplePrePutsIn(row)">申请领样</el-button>
            <el-button type="text" v-if="row.samplepreStatus === '1' " @click="samplePreparation(row, 1)">样品制备</el-button>
            <el-button type="text" v-if="row.samplepreStatus === '2' || row.samplepreStatus === '4' " @click="samplePreparation(row, 3)">修改</el-button>
            <el-button type="text" v-if="row.samplepreStatus === '3' || row.samplepreStatus === '5' " @click="samplePreparation(row, 2)">查看</el-button>
            <el-button type="text" v-if="row.samplepreStatus === '2' || row.samplepreStatus === '4' " @click="submitsSamplePre(row)">提交</el-button>
<!--            <el-button type="text" v-if="row.samplepreStatus === '5' " @click="warehouSamplesPre(row)">申请入库</el-button>-->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div style="float: right">
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"
      />
    </div>

    <!-- 样品制备 -->
    <el-dialog title="样品制备" :visible.sync="samplelinVisible" center width="70%" :close-on-click-modal="false">
      <div>
        <el-form :model="updateSamplelinForm" label-width="120px">
          <!--土壤/固废样品制备原始记录表-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">土壤/固废样品制备原始记录表</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="sampleNo" label="样品编号:">
                  <el-input v-model="updateSamplelinForm.sampleNo" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="laboratoryNo" label="实验室编号:">
                  <el-input v-model="updateSamplelinForm.laboratoryNo" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="fractureWeight" label="待碎样重量(g):">
                  <el-input type="number" v-model="updateSamplelinForm.fractureWeight" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="divisionKvalue" label="缩分k值:">
                  <el-input type="number" v-model="updateSamplelinForm.divisionKvalue" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <!--粗碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">粗碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="coarseCrushi" label="粗碎(mm):">
                  <el-input v-model="updateSamplelinForm.coarseCrushi" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="weightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.weightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="lossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.lossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="testSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.testSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="keepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.keepSubsample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeOneMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.crudeOneMistake" />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="fragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.fragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.crudeTwoMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--中碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">中碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="mesoclasm" label="中碎(mm):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasm" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmWeightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmLossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTestSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmTestSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmKeepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmKeepSubsample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmOneMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmOneMistake" />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmFragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmTwoMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">三次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmThreeFragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmThreeMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--细碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">细碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="comminution" label="细碎(mm):">
                  <el-input type="number" v-model="updateSamplelinForm.comminution" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionWeightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionLossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionTestSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionTestSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer" style="margin-top: -30px;float: right;">
        <el-button @click="samplelinVisible=false">取消</el-button>
        <el-button type="primary" @click="saveSamplePreparation">确认</el-button>
      </div>
    </el-dialog>

    <!-- 查看样品制备 -->
    <el-dialog title="查看样品制备" :visible.sync="modifySamplelinVisible" center width="70%" :close-on-click-modal="false">
      <div>
        <el-form :model="updateSamplelinForm" label-width="120px">
          <!--土壤/固废样品制备原始记录表-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">土壤/固废样品制备原始记录表</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="sampleNo" label="样品编号:">
                  <el-input v-model="updateSamplelinForm.sampleNo" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="laboratoryNo" label="实验室编号:">
                  <el-input v-model="updateSamplelinForm.laboratoryNo" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="fractureWeight" label="待碎样重量(g):">
                  <el-input type="number" v-model="updateSamplelinForm.fractureWeight" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="divisionKvalue" label="缩分k值:">
                  <el-input type="number" v-model="updateSamplelinForm.divisionKvalue" disabled />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <!--粗碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">粗碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="coarseCrushi" label="粗碎(mm):">
                  <el-input v-model="updateSamplelinForm.coarseCrushi" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="weightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.weightAfter" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="lossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.lossRate" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="testSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.testSample" disabled />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="keepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.keepSubsample" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeOneMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.crudeOneMistake" disabled />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="fragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.fragmentarySample" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.crudeTwoMistake" disabled />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--中碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">中碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="mesoclasm" label="中碎(mm):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasm" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmWeightAfter" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmLossRate" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTestSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmTestSample" disabled />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmKeepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmKeepSubsample" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmOneMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmOneMistake" disabled />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmFragmentarySample" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmTwoMistake" disabled />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">三次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmThreeFragmentarySample" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeMistake" label="误差(%):">
                  <el-input type="number" v-model="updateSamplelinForm.mesoclasmThreeMistake" disabled />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--细碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">细碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="comminution" label="细碎(mm):">
                  <el-input type="number" v-model="updateSamplelinForm.comminution" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionWeightAfter" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionLossRate" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionTestSample" label="检测样(g):">
                  <el-input type="number" v-model="updateSamplelinForm.comminutionTestSample" disabled />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer" style="margin-top: -30px;float: right;">
        <el-button @click="modifySamplelinVisible=false">取消</el-button>
      </div>
    </el-dialog>

    <!-- 批量制备样品 -->
    <el-dialog title="批量制备样品" :visible.sync="batchlinVisible" center width="70%" :close-on-click-modal="false">
      <div>
        <el-form :model="batchlinForm" label-width="120px">
          <!--土壤/固废样品制备原始记录表-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">土壤/固废样品制备原始记录表</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="laboratoryNo" label="实验室编号:">
                  <el-input v-model="batchlinForm.laboratoryNo" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="fractureWeight" label="待碎样重量(g):">
                  <el-input type="number" v-model="batchlinForm.fractureWeight" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="divisionKvalue" label="缩分k值:">
                  <el-input type="number" v-model="batchlinForm.divisionKvalue" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <!--粗碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">粗碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="coarseCrushi" label="粗碎(mm):">
                  <el-input v-model="batchlinForm.coarseCrushi" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="weightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="batchlinForm.weightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="lossRate" label="损耗率(%):">
                  <el-input type="number" v-model="batchlinForm.lossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="testSample" label="检测样(g):">
                  <el-input type="number" v-model="batchlinForm.testSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="keepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="batchlinForm.keepSubsample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeOneMistake" label="误差(%):">
                  <el-input type="number" v-model="batchlinForm.crudeOneMistake" />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="fragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="batchlinForm.fragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="crudeTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="batchlinForm.crudeTwoMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--中碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">中碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="mesoclasm" label="中碎(mm):">
                  <el-input type="number" v-model="batchlinForm.mesoclasm" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmWeightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmLossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTestSample" label="检测样(g):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmTestSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">一次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmKeepSubsample" label="留存副样(g):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmKeepSubsample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmOneMistake" label="误差(%):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmOneMistake" />
                </el-form-item>
              </el-col>
            </div>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 47%;float: right;margin-top: -38px;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">二次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmFragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmTwoMistake" label="误差(%):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmTwoMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <el-row>
            <div style="margin-bottom: 10px;background-color: #46a6ff26;font-size: 13px;padding-top: 5px;padding-bottom: 5px;width: 50%;">
              <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">三次缩分</span>
            </div>
            <div>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeFragmentarySample" label="待碎样(g):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmThreeFragmentarySample" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="mesoclasmThreeMistake" label="误差(%):">
                  <el-input type="number" v-model="batchlinForm.mesoclasmThreeMistake" />
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <!--细碎-->
          <div style="margin-bottom: 10px;background-color: #82848a38;font-size: 13px;padding-top: 5px;padding-bottom: 5px;">
            <span style="font-weight: bold;padding-left: 15px;font-family: '宋体'">细碎</span>
          </div>
          <div>
            <el-row>
              <el-col :span="6">
                <el-form-item prop="comminution" label="细碎(mm):">
                  <el-input type="number" v-model="batchlinForm.comminution" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionWeightAfter" label="筛后重(g):">
                  <el-input type="number" v-model="batchlinForm.comminutionWeightAfter" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionLossRate" label="损耗率(%):">
                  <el-input type="number" v-model="batchlinForm.comminutionLossRate" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item prop="comminutionTestSample" label="检测样(g):">
                  <el-input type="number" v-model="batchlinForm.comminutionTestSample" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer" style="margin-top: -30px;float: right;">
        <el-button @click="batchlinVisible=false">取消</el-button>
        <el-button type="primary" @click="batchSamplePreparation">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import * as samplelinServer from '@/api/samplelin'
  import Pagination from '@/components/Pagination'
  export default {
    components: { Pagination },
    data() {
      return {
        linSampItemData: [],
        searchForm: {
          fuzzy: '',
          sampTaskId: '',
          samplepreStatus: null,
          pageNumber: 1,
          pageSize: 10
        },
        total: 0,
        multipleSelection: [],

        updateSamplelinForm: {
          sampleItemId: '',
          sampleNo: '',
          laboratoryNo: '',
          fractureWeight: null,
          divisionKvalue: null,
          coarseCrushi: '',
          weightAfter: null,
          lossRate: null,
          testSample: null,
          keepSubsample: null,
          crudeOneMistake: null,
          fragmentarySample: null,
          crudeTwoMistake: null,
          mesoclasm: null,
          mesoclasmWeightAfter: null,
          mesoclasmLossRate: null,
          mesoclasmTestSample: null,
          mesoclasmKeepSubsample: null,
          mesoclasmOneMistake: null,
          mesoclasmFragmentarySample: null,
          mesoclasmTwoMistake: null,
          mesoclasmThreeFragmentarySample: null,
          mesoclasmThreeMistake: null,
          comminution: null,
          comminutionWeightAfter: null,
          comminutionLossRate: null,
          comminutionTestSample: null
        },
        samplelinVisible: false,
        modifySamplelinVisible: false,

        batchlinVisible: false,
        batchlinForm: {
          sampleItemIds: '',
          sampleNo: '',
          laboratoryNo: '',
          fractureWeight: null,
          divisionKvalue: null,
          coarseCrushi: '',
          weightAfter: null,
          lossRate: null,
          testSample: null,
          keepSubsample: null,
          crudeOneMistake: null,
          fragmentarySample: null,
          crudeTwoMistake: null,
          mesoclasm: null,
          mesoclasmWeightAfter: null,
          mesoclasmLossRate: null,
          mesoclasmTestSample: null,
          mesoclasmKeepSubsample: null,
          mesoclasmOneMistake: null,
          mesoclasmFragmentarySample: null,
          mesoclasmTwoMistake: null,
          mesoclasmThreeFragmentarySample: null,
          mesoclasmThreeMistake: null,
          comminution: null,
          comminutionWeightAfter: null,
          comminutionLossRate: null,
          comminutionTestSample: null
        },
      }
    },
    created() {
      this.handleSearch()
    },
    methods: {
      handleSearch() {
        this.searchForm.sampTaskId = this.$route.params.sampTaskId;
        samplelinServer.findSampleItemBySampTaskId(this.searchForm).then(res => {
          if (res.code === 200) {
            this.linSampItemData = res.result.records
            this.total = res.result.total
          }
        })
      },

      handleSelectionChange(val) {
        this.multipleSelection = val
      },

      // 样品制备--申请领样
      samplePrePutsIn(row) {
        this.$confirm('确定申请领样吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let samplePutInData = {sampItemId: row.sampItemId, sampTaskId: row.sampTaskId, sampleNo: row.sampleNo}
          samplelinServer.samplePrePutIn(samplePutInData).then(res => {
            if (res.code === 200) {
              this.$notify({
                title: '成功',
                message: res.message,
                type: 'success'
              })
              this.handleSearch()
            } else {
              this.$notify({
                title: '失败',
                message: res.message,
                type: 'error'
              })
            }
          })
        }).catch(() => {})
      },

      // 样品制备
      samplePreparation(row, type) {
        samplelinServer.findSamplePutIn({sampleItemId: row.sampItemId}).then(res => {
          if (res.code === 200) {
            if (res.result == null && type === 1){
              this.$message.error('样品制备还未出库，无法样品制备！')
              return
            }else {
              this.updateSamplelinForm.sampleNo = ''
              this.updateSamplelinForm.laboratoryNo = ''
              this.updateSamplelinForm.fractureWeight = null
              this.updateSamplelinForm.divisionKvalue = null
              this.updateSamplelinForm.coarseCrushi = ''
              this.updateSamplelinForm.weightAfter = null
              this.updateSamplelinForm.lossRate = null
              this.updateSamplelinForm.testSample = null
              this.updateSamplelinForm.keepSubsample = null
              this.updateSamplelinForm.crudeOneMistake = null
              this.updateSamplelinForm.fragmentarySample = null
              this.updateSamplelinForm.crudeTwoMistake = null
              this.updateSamplelinForm.mesoclasm = null
              this.updateSamplelinForm.mesoclasmWeightAfter = null
              this.updateSamplelinForm.mesoclasmLossRate = null
              this.updateSamplelinForm.mesoclasmTestSample = null
              this.updateSamplelinForm.mesoclasmKeepSubsample = null
              this.updateSamplelinForm.mesoclasmOneMistake = null
              this.updateSamplelinForm.mesoclasmFragmentarySample = null
              this.updateSamplelinForm.mesoclasmTwoMistake = null
              this.updateSamplelinForm.mesoclasmThreeFragmentarySample = null
              this.updateSamplelinForm.mesoclasmThreeMistake = null
              this.updateSamplelinForm.comminution = null
              this.updateSamplelinForm.comminutionWeightAfter = null
              this.updateSamplelinForm.comminutionLossRate = null
              this.updateSamplelinForm.comminutionTestSample = null
              // 查看样品制备
              samplelinServer.findSampItemPreVo({sampleItemId: row.sampItemId}).then(res => {
                if (res.code === 200) {
                  if (res.result != null){
                    this.updateSamplelinForm.sampleNo = res.result.sampleNo
                    this.updateSamplelinForm.laboratoryNo = res.result.laboratoryNo
                    this.updateSamplelinForm.fractureWeight = res.result.fractureWeight
                    this.updateSamplelinForm.divisionKvalue = res.result.divisionKvalue
                    this.updateSamplelinForm.coarseCrushi = res.result.coarseCrushi
                    this.updateSamplelinForm.weightAfter = res.result.weightAfter
                    this.updateSamplelinForm.lossRate = res.result.lossRate
                    this.updateSamplelinForm.testSample = res.result.testSample
                    this.updateSamplelinForm.keepSubsample = res.result.keepSubsample
                    this.updateSamplelinForm.crudeOneMistake = res.result.crudeOneMistake
                    this.updateSamplelinForm.fragmentarySample = res.result.fragmentarySample
                    this.updateSamplelinForm.crudeTwoMistake = res.result.crudeTwoMistake
                    this.updateSamplelinForm.mesoclasm = res.result.mesoclasm
                    this.updateSamplelinForm.mesoclasmWeightAfter = res.result.mesoclasmWeightAfter
                    this.updateSamplelinForm.mesoclasmLossRate = res.result.mesoclasmLossRate
                    this.updateSamplelinForm.mesoclasmTestSample = res.result.mesoclasmTestSample
                    this.updateSamplelinForm.mesoclasmKeepSubsample = res.result.mesoclasmKeepSubsample
                    this.updateSamplelinForm.mesoclasmOneMistake = res.result.mesoclasmOneMistake
                    this.updateSamplelinForm.mesoclasmFragmentarySample = res.result.mesoclasmFragmentarySample
                    this.updateSamplelinForm.mesoclasmTwoMistake = res.result.mesoclasmTwoMistake
                    this.updateSamplelinForm.mesoclasmThreeFragmentarySample = res.result.mesoclasmThreeFragmentarySample
                    this.updateSamplelinForm.mesoclasmThreeMistake = res.result.mesoclasmThreeMistake
                    this.updateSamplelinForm.comminution = res.result.comminution
                    this.updateSamplelinForm.comminutionWeightAfter = res.result.comminutionWeightAfter
                    this.updateSamplelinForm.comminutionLossRate = res.result.comminutionLossRate
                    this.updateSamplelinForm.comminutionTestSample = res.result.comminutionTestSample
                  }
                }
              })
              this.updateSamplelinForm.sampleItemId = row.sampItemId
              if (type === 1){
                this.samplelinVisible = true
              }else if (type === 2){
                this.modifySamplelinVisible = true
              }else if (type === 3){
                this.samplelinVisible = true
              }
            }
          }
        })
      },

      // 保存--修改样品制备
      saveSamplePreparation() {
        samplelinServer.updateSampPreEnte(this.updateSamplelinForm).then(res => {
          if (res.code === 200) {
            this.$notify({
              title: '成功',
              message: res.message,
              type: 'success'
            })
            this.samplelinVisible = false;
            this.updateSamplelinForm = {
              sampleItemId: '',
                sampleNo: '',
                laboratoryNo: '',
                fractureWeight: null,
                divisionKvalue: null,
                coarseCrushi: '',
                weightAfter: null,
                lossRate: null,
                testSample: null,
                keepSubsample: null,
                crudeOneMistake: null,
                fragmentarySample: null,
                crudeTwoMistake: null,
                mesoclasm: null,
                mesoclasmWeightAfter: null,
                mesoclasmLossRate: null,
                mesoclasmTestSample: null,
                mesoclasmKeepSubsample: null,
                mesoclasmOneMistake: null,
                mesoclasmFragmentarySample: null,
                mesoclasmTwoMistake: null,
                mesoclasmThreeFragmentarySample: null,
                mesoclasmThreeMistake: null,
                comminution: null,
                comminutionWeightAfter: null,
                comminutionLossRate: null,
                comminutionTestSample: null
            };
            this.handleSearch();
          } else {
            this.$notify({
              title: '失败',
              message: res.message,
              type: 'error'
            })
          }
        })
      },

      // 样品制备--提交
      submitsSamplePre(row) {
        this.$confirm('确定提交吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let samplePutInData = {sampleItemId: row.sampItemId}
          samplelinServer.submitSamplePre(samplePutInData).then(res => {
            if (res.code === 200) {
              this.$notify({
                title: '成功',
                message: res.message,
                type: 'success'
              })
              this.handleSearch()
            } else {
              this.$notify({
                title: '失败',
                message: res.message,
                type: 'error'
              })
            }
          })
        }).catch(() => {})
      },

      // 样品制备--申请入库
      warehouSamplesPre(row) {
        this.$confirm('确定入库吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let samplePutInData = {sampleItemId: row.sampItemId}
          samplelinServer.warehouSamplePre(samplePutInData).then(res => {
            if (res.code === 200) {
              this.$notify({
                title: '成功',
                message: res.message,
                type: 'success'
              })
              this.handleSearch()
            } else {
              this.$notify({
                title: '失败',
                message: res.message,
                type: 'error'
              })
            }
          })
        }).catch(() => {})
      },

      checkSelectableOne(item) {
        if (item.samplepreStatus === '1') {
          return true
        }else {
          return false
        }
      },

      handleBatchPreOne() {
        if (this.multipleSelection && this.multipleSelection.length > 0) {
          const sampItemIds = this.multipleSelection.map(i => {
            return i.sampItemId
          })
          this.batchlinForm.sampleItemIds = sampItemIds
          samplelinServer.plFindSamplePutIn({sampleItemIds: this.batchlinForm.sampleItemIds}).then(res => {
            if (res.code === 200) {
              if (res.result === false){
                this.$message.error('样品制备还未出库，无法样品制备！')
                return
              }else {
                this.batchlinVisible = true
              }
            }
          })
        } else {
          this.$message.warning('当前没有选择要制备样品的数据')
        }
      },

      // 批量修改样品制备
      batchSamplePreparation() {
        samplelinServer.batchSamplePreEnte(this.batchlinForm).then(res => {
          if (res.code === 200) {
            this.$notify({
              title: '成功',
              message: res.message,
              type: 'success'
            })
            this.batchlinVisible = false;
            this.batchlinForm = {
              sampleItemIds: '',
                sampleNo: '',
                laboratoryNo: '',
                fractureWeight: null,
                divisionKvalue: null,
                coarseCrushi: '',
                weightAfter: null,
                lossRate: null,
                testSample: null,
                keepSubsample: null,
                crudeOneMistake: null,
                fragmentarySample: null,
                crudeTwoMistake: null,
                mesoclasm: null,
                mesoclasmWeightAfter: null,
                mesoclasmLossRate: null,
                mesoclasmTestSample: null,
                mesoclasmKeepSubsample: null,
                mesoclasmOneMistake: null,
                mesoclasmFragmentarySample: null,
                mesoclasmTwoMistake: null,
                mesoclasmThreeFragmentarySample: null,
                mesoclasmThreeMistake: null,
                comminution: null,
                comminutionWeightAfter: null,
                comminutionLossRate: null,
                comminutionTestSample: null
            },
            this.handleSearch();
          } else {
            this.$notify({
              title: '失败',
              message: res.message,
              type: 'error'
            })
          }
        })
      },

      // 样品制备--批量申请领样
      batchSamplePresPutIn() {
        if (this.linSampItemData.length > 0){
          let item = this.linSampItemData.findIndex(i => {return i.samplepreStatus === null});
          if (item === -1){
            this.$message.warning('至少有一条待领样的数据，才能进行领样操作')
            return
          }
        }else {
          this.$message.warning('当前没有要操作的数据')
          return
        }
        let sampTaskId = {sampTaskId: this.searchForm.sampTaskId}
        samplelinServer.batchSamplePrePutIn(sampTaskId).then(res => {
          if (res.code === 200) {
            this.$notify({
              title: '成功',
              message: res.message,
              type: 'success'
            })
            this.handleSearch()
          } else {
            this.$notify({
              title: '失败',
              message: res.message,
              type: 'error'
            })
          }
        })
      },

      // 一键申请入库
      batchsWarehouSampPre() {
        if (this.linSampItemData.length > 0){
          let item = this.linSampItemData.findIndex(i => {return i.samplepreStatus === '5'});
          if (item === -1){
            this.$message.warning('至少有一条待入库的数据，才能进行入库操作')
            return
          }
        }else {
          this.$message.warning('当前没有要操作的数据')
          return
        }
        let sampTaskId = {sampTaskId: this.searchForm.sampTaskId}
        samplelinServer.batchWarehousSampPre(sampTaskId).then(res => {
          if (res.code === 200) {
            this.$notify({
              title: '成功',
              message: res.message,
              type: 'success'
            })
            this.handleSearch()
          } else {
            this.$notify({
              title: '失败',
              message: res.message,
              type: 'error'
            })
          }
        })
      },

    }
  }
</script>

<style scoped lang="scss" type="text/scss">
  .search_div {
    >div {
      &:nth-child(1){
        margin-right: 10px;
      }
      display: inline-block;
    }
  }
  .search_input {
    width: 200px;
    margin-bottom: 5px;
  }
  .search-right {
    text-align: right;
    padding-right: 25px;
  }
  .item {
    font-size: 16px;
  }
  ::v-deep .el-card .el-card__header {
    padding: 5px 20px;
    background: #F3F2F2;
  }
  .apostrophe{
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
</style>
